from redis import StrictRedis
import base64
import os

def generate_csrf():
    """随机生成字符串"""
    return base64.b64encode(os.urandom(48)).decode()
class Config(object):
    DEBUG = True

    SECRET_KEY = generate_csrf()
    # 配置数据库的链接
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@localhost/python6'
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # 状态保持的session信息存储在redis数据库中
    SESSION_TYPE = 'redis'
    SESSION_REDIS = StrictRedis()  # 指定session信息链接的数据库实例,使用默认连接本地仓库
    SESSION_USE_SIGNER = True  # 对session信息进行签名
    PERMANENT_SESSION_LIFETIME = 86400  # 指定session信息的有效期
class developmentConfig(Config):
    DEBUG = True

class productionConfig(Config):
    DEBUG = False

config = {

    "development": developmentConfig,
    "production": productionConfig

}